Limit the number of characters in stringΒΆ

Format a specified string to limit the number of characters to 6.
str_num = "1234567890"

print('%.6s' % str_num)
print(str_num[:6])

Output:

123456
123456